<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="/common/layui/css/layui.css"/>
    <link rel="stylesheet" href="/css/global.css">
    <!--<style>.layui-input {-->
    <!--width: 380px;-->
    <!--}</style>-->
</head>
<body>
<form class="layui-form" action="">
    <div class="layui-form-item">
        <label class="layui-form-label">小组名称</label>
        <div class="layui-input-inline">
            <input type="hidden" name="id" class="layui-input id">
            <input type="text" name="teamName" required lay-verify="required" placeholder="请输入小组名称" autocomplete="off"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">组长</label>
        <div class="layui-input-block">
            <select name="teamLeaderId">
                <option value=""></option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="formSubmit">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
</body>
<script src="/common/layui/layui.js"></script>
<script src="/js/global.js"></script>
<script>
    layui.use(['form', 'jquery'], function () {
        let $ = layui.jquery;
        let searchParams = parseSearchParams();
        if (!isEmpty(searchParams.method) && searchParams.method === "insert") {
            $(".layui-form-item:eq(1)").hide();
        }
        let form = layui.form;
        form.on('submit(formSubmit)', function (data) {
            let params = filterFormOnNull(data.field);
            ajax("/admin/team/update", "POST", params, (res) => {
                let icon = 2;
                if (res.code === 0) {
                    icon = 1;
                    parent.layui.table.reload("groupTable");
                    let index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                    parent.layer.close(index); //再执行关闭
                }
                parent.layer.msg(res.msg, {icon: icon, offset: 'rt'});
            });
            return false;
        });
    });
</script>
</html>